package com.mes.data.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mes.common.core.utils.poi.ExcelUtil;
import com.mes.common.core.web.controller.BaseController;
import com.mes.common.core.web.domain.AjaxResult;
import com.mes.common.core.web.page.TableDataInfo;
import com.mes.common.log.annotation.Log;
import com.mes.common.log.enums.BusinessType;
import com.mes.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mes.data.domain.SensorList;
import com.mes.data.service.ISensorListService;

/**
 * 传感器采集Controller
 * 
 * @author itflash
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/data/sensorList")
public class SensorListController extends BaseController
{
    @Autowired
    private ISensorListService sensorListService;

    /**
     * 查询传感器采集列表
     */
    @RequiresPermissions("data:sensorList:list")
    @GetMapping("/list")
    public TableDataInfo list(SensorList sensorList)
    {
        startPage();
        List<SensorList> list = sensorListService.selectSensorListList(sensorList);
        return getDataTable(list);
    }

    /**
     * 导出传感器采集列表
     */
    @RequiresPermissions("data:sensorList:export")
    @Log(title = "传感器采集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SensorList sensorList)
    {
        List<SensorList> list = sensorListService.selectSensorListList(sensorList);
        ExcelUtil<SensorList> util = new ExcelUtil<SensorList>(SensorList.class);
        util.exportExcel(response, list, "传感器采集数据");
    }

    /**
     * 获取传感器采集详细信息
     */
    @RequiresPermissions("data:sensorList:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sensorListService.selectSensorListById(id));
    }

    /**
     * 新增传感器采集
     */
    @RequiresPermissions("data:sensorList:add")
    @Log(title = "传感器采集", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SensorList sensorList)
    {
        return toAjax(sensorListService.insertSensorList(sensorList));
    }

    /**
     * 修改传感器采集
     */
    @RequiresPermissions("data:sensorList:edit")
    @Log(title = "传感器采集", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SensorList sensorList)
    {
        return toAjax(sensorListService.updateSensorList(sensorList));
    }

    /**
     * 删除传感器采集
     */
    @RequiresPermissions("data:sensorList:remove")
    @Log(title = "传感器采集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sensorListService.deleteSensorListByIds(ids));
    }
}
